

/*------------------------------------------------------------------------------
	1. Housekeeping
------------------------------------------------------------------------------*/

	*Run housekeeping code
		qui do ".../replication_package/housekeeping.do"

	*Write log
		log using "$log_loc/maternal_wage_num_2018.log", text replace

/*------------------------------------------------------------------------------
	2. Clean Main dataset
------------------------------------------------------------------------------*/

		*Import Data
		use "$data/childrens2018_w_w2.dta", clear
			drop _merge

			/*Restrict Sample*/
				*Keep 1095 filings
					rename state_insurance state
					fmerge m:1 state using "$data/statelist.dta"
						assert _merge != 2 //Confirm that all 51 states are in dataset
						drop if _merge != 3
						drop _merge

				*Keep if age_num is within the range
					keep if age_num >= 0 & age_num <= 16

				*Keep if kid died after end of year or is currently alive
					keep if 2018*10000+1231<death_date|death_date==0

				*Keep if months covered is possible
					keep if num_cov_ins > 0 & num_cov_ins <= 12
	
			/*Generate variables for figure*/
				*Generate outcome variable on claiming
					gen onreturn = file_inc != .

				*Generate a ct variable
					gen ct = 1

				*Rescale Claimed Variable to be between 1 and 100
					replace onreturn = onreturn * 100

				*Adjust for claiming limits
					replace onreturn = onreturn * 1.0017029

/*------------------------------------------------------------------------------
	4. Create Figures
------------------------------------------------------------------------------*/

			/*Generate figures*/
				*Create Binned Scatter Plots (for Moms)				
					binscatter onreturn mom_med_wage_nums if mom_med_wage_nums > 0 & mom_med_wage_nums < 100000, nq(100) ///
						xtitle("Wages ($)") ytitle("% Children Claimed") ///
						xlabel(0(20000)100000, format(%10.0fc) labsize(small)) linetype(none)

					*Save out Figure
						graph export "${output}/2018 mom income.png", replace as(png)

